#include <stdlib.h>
#include <stdio.h>

#include "../util.h"

void insectionSort(int *arr, int n)
{

    for (int i = 1; i < n; i++)
    {
        int key = arr[i];

        int j = i - 1;

        while (j >= 0 && arr[j] > key)
        {
            arr[j + 1] = arr[j]; // 后移
            j--;
        }

        arr[j + 1] = key; // 填到合适的位置
        }
}

int main()
{
    int arr[5] = {5, 6, 3, 6, 1};
    insectionSort(arr, 5);

    prinftArr(arr, 5);

    return 0;
}